<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原创软件用户管理 - 登陆</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .login-container {
            background: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            width: 300px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .button-group {
            display: flex;
            gap: 10px;
            margin-top: 15px;
        }
        .btn {
            flex: 1;
            padding: 10px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-align: center;
            text-decoration: none;
            color: white;
        }
        .btn-login {
            background-color: #007bff;
        }
        .btn-register {
            background-color: #28a745;
        }
        .btn:hover {
            opacity: 0.9;
        }
        .error-message {
            color: #dc3545;
            margin-top: 10px;
            text-align: center;
            padding: 10px;
            background-color: #f8d7da;
            border-radius: 4px;
            border: 1px solid #f5c6cb;
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1000;
            animation: fadeOut 3s forwards;
        }
        @keyframes fadeOut {
            0% { opacity: 1; }
            70% { opacity: 1; }
            100% { opacity: 0; }
        }
        .captcha-group {
            display: flex;
            gap: 10px;
            align-items: center;
        }
        .captcha-input {
            flex: 1;
        }
        .captcha-image {
            height: 30px;
            cursor: pointer;
        }
    </style>
    <script>
        // 页面加载时检查错误参数
        window.onload = function() {
            const urlParams = new URLSearchParams(window.location.search);
            if (urlParams.has('error')) {
                const errorDiv = document.createElement('div');
                errorDiv.className = 'error-message';
                
                // 根据错误类型显示不同消息
                if (urlParams.get('error') === '1') {
                    errorDiv.textContent = '用户名或密码错误，或该用户无权登录系统！';
                } else if (urlParams.get('error') === '2') {
                    errorDiv.textContent = '验证码错误！';
                }
                
                document.body.appendChild(errorDiv);
                
                // 3秒后移除消息并清除URL参数
                setTimeout(() => {
                    errorDiv.remove();
                    window.history.replaceState({}, document.title, window.location.pathname);
                }, 3000);
            }
        }
    </script>
</head>
<body>
    <div class="login-container">
        <h2>用户登录</h2>
        <form action="auth.php" method="post">
            <div class="form-group">
                <label for="username">用户名：</label>
                <input type="text" id="username" name="username" required>
            </div>
            <div class="form-group">
                <label for="password">密码：</label>
                <input type="password" id="password" name="password" required>
            </div>
            <div class="form-group">
                <label for="captcha">验证码：</label>
                <div class="captcha-group">
                    <input type="text" id="captcha" name="captcha" class="captcha-input" required maxlength="4">
                    <img src="captcha.php" alt="验证码" class="captcha-image" onclick="this.src='captcha.php?'+Math.random()">
                </div>
            </div>
            <div class="button-group">
                <button type="submit" class="btn btn-login">登录</button>
                <a href="register.php" class="btn btn-register">注册</a>
            </div>
        </form>
    </div>
</body>
</html> 